<?php
	/*
		DreamCMS Version 1.0
		Developed by: Andrei Mikalov (Zeus)
		
		Thanks to Adam Davis
	*/
	require_once("models/config.php");
	
	//Prevent the user visiting the logged in page if he/she is already logged in
	if(isUserLoggedIn()) { header("Location: account.php"); die(); }
	
		$pagename= "Account Activation"
?>
<?php
	/* 
		Activate a users account
	*/
$errors = array();

//Get token param
if(isset($_GET["token"]))
{
		
		$token = $_GET["token"];
		
		if(!isset($token))
		{
			$errors[] = lang("FORGOTPASS_INVALID_TOKEN");
		}
		else if(!validateActivationToken($token)) //Check for a valid token. Must exist and active must be = 0
		{
			$errors[] = "Token does not exist / Account is already activated";
		}
		else
		{
			//Activate the users account
			if(!setUserActive($token))
			{
				$errors[] = lang("SQL_ERROR");
			}
		}
}
else
{
	$errors[] = lang("FORGOTPASS_INVALID_TOKEN");
}
?>
<?php include("layout_inc/header.php"); ?>
<div id="content_main">
           <h3>Account Activation</h3>
            <p>
            <?php
				if(count($errors) > 0)
				{
            ?>
            <div id="errors">
            <?php errorBlock($errors); ?>
            </div>     
            <?php
           		 } else { ?> 
        <div id="success">
        
           <p><?php echo lang("ACCOUNT_NOW_ACTIVE"); ?></p>
           
        </div>
        <?php }?>
            </p>
                
            
        </div>
    
    <div id="nav_main">
        <h4>Navigation</h4>
        <ul>
          <?php include("layout_inc/right-nav.php"); ?>
        </ul>
    </div>
    
    
</div>

<div id="footer">
<div id="copyright"></div>
Powered by DreamCMS Version 1 <br />
Copyright &copy Andrei Mikalov & Adam Davis <br />
Thanks to Zymic.com for the template.
        <ul id="nav_footer">
        
        </ul>
    
</div>

</body>
</html>
